home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lang_c
/
mixisam
/
istest2.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-07-19
|
2KB
|
62 lines
/* ISAM test program #2. This program will serve to test the ISAM library */
/* functions we have created, and, when successfully executed, should serve */
/* as a model for any future programs incorporating the ISAM libraries. */
#include "rarisam.c"
FILE *print_file;
Db_Obj *phone_database;
Index_Obj *phone_index;
char name[21] = " ";
char phone_area[4] = " ";
char phone_exchange[4] = " ";
char phone_body[5] = " ";
char *phone_format[] = {
"name",
"area code",
"exchange",
"body number",
NULL
};
char *phone_index_format[] = {
"name",
NULL
};
main()
{
print_file = fopen("lpt1", "a");
isam_open(&phone_database, "phone", &phone_index, "name");
isam_search(phone_database, phone_index, "Dean");
move_data_to_fields();
fprintf(print_file, "Name: %s. Phone: (%s) %s-%s.\n", name, phone_area,
phone_exchange, phone_body);
isam_next(phone_database, phone_index);
move_data_to_fields();
fprintf(print_file, "Name: %s. Phone: (%s) %s-%s.\n", name, phone_area,
phone_exchange, phone_body);
isam_prev(phone_database, phone_index);
move_data_to_fields();
fprintf(print_file, "Name: %s. Phone: (%s) %s-%s.\n", name, phone_area,
phone_exchange, phone_body);
isam_prev(phone_database, phone_index);
move_data_to_fields();
fprintf(print_file, "Name: %s. Phone: (%s) %s-%s.\n", name, phone_area,
phone_exchange, phone_body);
fprintf(print_file, "END OF RUN\n");
fclose(print_file);
isam_close(phone_database);
}
move_data_to_fields()
{
strcpy(name, *(fields + 0));
strcpy(phone_area, *(fields + 1));
strcpy(phone_exchange, *(fields + 2));
strcpy(phone_body, *(fields + 3));
}